<?php

class TradeItemUpperOrLowerShelfAction extends SzAbstractAction
{
    Protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
    );

    /**
     * @param $userId
     * @param $position
     * @param $upAndDown
     * @param $itemId
     * @param $num
     * @param $price
     * @param $reqTime
     * @return SzResponse
     * @throws SzException
     */
    public function execute($userId,$position,$upAndDown,$itemId,$num,$price,$reqTime) {
        if (!GameService::get()->verifySysUnlock($userId, GameConst::FUNC_TRADE_FUNC)) {
            return $this->buildResponse(false);
        }

        if ($upAndDown == 1){
            return $this->buildResponse(
                TradeItemService::get()->upperShelf($userId,$position,$itemId,$num,$price,$reqTime)
            );
        }

        if ($upAndDown == 2){
            return $this->buildResponse(
                TradeItemService::get()->downShelf($userId,$position,$itemId,$num,$reqTime)
            );
        }
    }
}